package userInterface;

import java.io.File;
import java.util.regex.*;

import javax.swing.filechooser.FileFilter;

public class ImageFileFilter extends FileFilter {
    	Pattern extPattern;
    	String ext;
    	public ImageFileFilter(String t) {
    		this.ext=t;
    		this.extPattern=Pattern.compile("\\w*\\.".concat(t),Pattern.CASE_INSENSITIVE);
    	}
    	public boolean accept(File file) {
    		if (file.isDirectory())
    			return true;
    		
    		String fileName=file.getName();
    		if (extPattern.matcher(fileName).find())
    			return true;
    		return false;
    		
    	}
		@Override
		public String getDescription() {
			if (ext.equals("bmp"))
				return "位图文件";
			if (ext.equals("logo"))
				return "LOGO Script";
			return "";
		}
}
